﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Composite_Pattern
{
    class SongGroup : SongComponent
    {
        public List<SongComponent> songComponents = new List<SongComponent>();

        public string groupName;
        public string groupDescription;

        public SongGroup(string newGroupName, String newGroupDescription)
        {
            this.groupName = newGroupName;
            this.groupDescription = newGroupDescription;
        }

        public override void add(SongComponent newSongComponent)
        {
            songComponents.Add(newSongComponent);
        }

        public override void remove(SongComponent songComponent)
        {
            songComponents.Remove(songComponent);
        }

        public SongComponent getComponent(int componentIndex)
        {
            return songComponents[componentIndex];
        }

        public override void displaySongInfo()
        {
            Console.WriteLine(groupName + " - " + groupDescription + "\n");
            IEnumerator songIterator = songComponents.GetEnumerator();

            while (songIterator.MoveNext())
            {
                SongComponent songInfo = (SongComponent)songIterator.Current;
                songInfo.displaySongInfo();
            }
        }

    }
}
